package ljh;


import java.util.HashMap;
import java.util.Map;

public class Test1 {
    public static void main(String[] args) {
        OutletConstructProgress progess = new OutletConstructProgress();
        progess.setProjectApprovalFlag(true);
        progess.setDesignExtReviewFlag(true);
        progess.setStartFlag(true);   // 已开工
        progess.setFinishFlag(false);
        progess.setFinishFlag(false);
        System.out.println(getLatestConstructProgress(progess));
    }


    private static String getLatestConstructProgress(OutletConstructProgress progess) {
        Map<String,Boolean> map = new HashMap<>();
        map.put("APPROVAL", progess.isProjectApprovalFlag());
        map.put("DESIGN", progess.isDesignExtReviewFlag());
        map.put("START", progess.isStartFlag());
        map.put("FINISH", progess.isFinishFlag());
        map.put("OPEN", progess.isOpenFlag());

        String lastTrueKey = null;
        for(Map.Entry<String, Boolean> entry : map.entrySet()) {
            if(entry.getValue()) {
                lastTrueKey = entry.getKey();
            }
        }
        if(lastTrueKey != null) {
            for(ConstructProgressType type : ConstructProgressType.values()) {
                if(lastTrueKey.equals(type.name())) {
                    return type.getType();
                }
            }
        }

        return null;
    }
}
